home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / dskutil / 2m30src.zip / 2M-INFO.C < prev    next >
C/C++ Source or Header  |  1995-03-06  |  39KB  |  1,346 lines

  1.  
  2. /*───────────────────────────────────────────────────────────────────\
  3. │                                                                    │
  4. │              █████ █   █     ▀▀█▀▀ █▀▀▀▀█ █▀▀▀▀ █▀▀▀█              │
  5. │                  █ ██ ██       █   █    █ █     █   █              │
  6. │              █████ █ █ █  ▄▄▄  █   █    █ █▀▀   █   █              │
  7. │              █     █   █       █   █    █ █     █   █              │
  8. │              █████ █   █     ▄▄█▄▄ █    █ █     █▄▄▄█              │
  9. │                                                                    │
  10. │         2M-INFO 3.0  -  UTILIDAD DE DOCUMENTACION SOBRE 2M         │
  11. │                                                                    │
  12. │               (C) 1994-1995 Ciriaco García de Celis.               │
  13. │                                                                    │
  14. │ - Para cualquier Turbo C o Borland C++ en modelo de memoria LARGE. │
  15. │ - Este programa se compila abriendo un proyecto e introduciendo en │
  16. │   él 2M-INFO.C, 2M-IN765.C, 2M-INFDT.C, 2M-INDOC.C y 2M-INF.ASM    │
  17. │                                                                    │
  18. \───────────────────────────────────────────────────────────────────*/
  19.  
  20.  
  21. #include <bios.h>
  22. #include <dos.h>
  23. #include <alloc.h>
  24. #include <string.h>
  25. #include <io.h>
  26. #include <fcntl.h>
  27. #include <math.h>
  28. #include <stdlib.h>
  29. #include <stdio.h>
  30. #include <conio.h>
  31. #include "2m-info.h"
  32.  
  33.  
  34. unsigned _stklen = 16384;
  35.  
  36.  
  37. #define FICH_FMC "2M-INFO.FMC"
  38. #define FICH_DOC "2M-INFO.FDA"
  39. #define FICH_IDX "2M-INFO.IDX"
  40. #define FALTA_FMC   1
  41. #define POCA_MEM    2
  42. #define ERROR_FMC   4
  43.  
  44.  
  45. #define R 0
  46. #define G 1
  47. #define B 2
  48.  
  49.  
  50. extern void debug765 (void);
  51. extern void fdtr (int, int);
  52. extern void vgahi256 (void);
  53. extern void setpix (int, int, int);
  54. extern void setpage (int);
  55. extern void showpage (int);
  56. extern void prcar (int, int, int, int, int, int, int, int);
  57. extern void PintaBitMap (char *, int, int, int, int, int, int, int, int);
  58. extern int VerFicheroDoc (char *, char *, char *, Parametros *);
  59. extern int getpix (int, int);
  60. extern int ptecla (char);
  61. extern int segvideo;
  62. extern int semilla;
  63. extern unsigned rnd (unsigned);
  64. extern char far *FuenteInfo;
  65.  
  66.  
  67. int  HablaSp (void),
  68.      ExisteVga (void),
  69.      Tecla (void),
  70.      Hay2M3 (void),
  71.      EsOS2 (void),
  72.      EsWinEnh (void),
  73.      Luminosidad (int),
  74.      VgaPantallaIni (void),
  75.      CargarGalaxia (void),
  76.      input (char *, int, int, int, int);
  77. void Vram (int),
  78.      Ayuda (void),
  79.      ProcesaParametros (int, char **, Parametros *),
  80.      ImprimirError (int),
  81.      VgaPantallaFin (void),
  82.      Estrellas (void),
  83.      escribir2M (char *),
  84.      LogoTxt (void),
  85.      CursorOff (void),
  86.      BrilloOn (void),
  87.      TxtPantallaIni (void),
  88.      TxtPantallaFin (void),
  89.      Trampa (int),
  90.      PaletaIni (void),
  91.      PaletaFin (void),
  92.      Paciencia (void),
  93.      prcad (char *, int, int, int, int, int, int, int),
  94.      Imprimir2M (void),
  95.      ImprimirLogo (void),
  96.      ImprimirCardWare (void),
  97.      ventana (int, int, int, int, int, int, int),
  98.      Marco3dg (int, int, int, int, int, int, int, int),
  99.      v3dg (int, int, int, int, int, int, int, int, int),
  100.      v3d (int, int, int, int, int),
  101.      Marco3df (int, int, int, int, int, int, int),
  102.      v3df (int, int, int, int, int, int, int, int),
  103.      boton (int, int, int, int, int, int, char *);
  104. char *dec2str (unsigned),
  105.      *dec3str (unsigned),
  106.      *dec5str (unsigned),
  107.      *dec2strq (unsigned),
  108.      *dec3strq (unsigned),
  109.      *dec5strq (unsigned);
  110.  
  111.  
  112. char *KeybShifts = MK_FP (0x40, 0x17);
  113. int   sp;                               /* 1-español 0-inglés */
  114. char  ruta[64];                         /* directorio de ejecución */
  115.  
  116.  
  117. void Vram (int operacion)
  118. {
  119.   static scr_ok, modo, pag, cx, cy, colorbits;
  120.   static char *scrbuf;
  121.   union REGS regs;
  122.  
  123.   if (operacion==PRESERVAR) {
  124.     scr_ok=0;
  125.     modo=peekb(0x40, 0x49) & 0x7F;
  126.     if (peekb(0x40, 0x84) < 24) pokeb(0x40, 0x84, 24);
  127.     if ((modo<=3)||(modo==7)) {
  128.       if ((scrbuf=farmalloc(4096L))!=NULL) {
  129.         scr_ok=1;
  130.         movedata ((modo==7) ? 0xb000: 0xb800,
  131.                   (modo==7) ? 0     : peek(0x40, 0x4e),
  132.                   FP_SEG(scrbuf), FP_OFF(scrbuf), 4096);
  133.         pag=peekb(0x40,0x62);
  134.         cx=peekb(0x40,0x50+pag*2); cy=peekb(0x40,0x51+pag*2);
  135.         colorbits=peek(0x40, 0x10) & 0x30;
  136.         textmode ((modo!=7) ? C80:MONO);
  137.         }
  138.       }
  139.     }
  140.     else if ((operacion==RESTAURAR) || (operacion==MOSTRAR)) {
  141.       poke (0x40, 0x10, peek(0x40, 0x10) & 0xFFCF | colorbits);
  142.       regs.x.ax=modo; int86 (0x10, ®s, ®s);
  143.       if (scr_ok) {
  144.           regs.x.ax=0x500+pag; int86 (0x10, ®s, ®s);
  145.           movedata (FP_SEG(scrbuf), FP_OFF(scrbuf),
  146.                     (modo==7) ? 0xb000 : 0xb800,
  147.                     (modo==7) ? 0      : peek(0x40, 0x4e), 4096);
  148.           regs.x.ax=0x200; regs.x.bx=pag<<8;
  149.           regs.h.dh=cy; regs.h.dl=cx; int86 (0x10, ®s, ®s);
  150.           if (operacion==RESTAURAR) farfree(scrbuf);
  151.           }
  152.       }
  153. }
  154.  
  155.  
  156. void Ayuda (void)
  157. {
  158.   if (sp)
  159.       printf("\n2M-INFO 3.0\n"
  160.              "   /Q  Evitar la pantalla de presentación  (equivale a dejar pulsada\n"
  161.              "       alguna tecla MAYUSCULAS al entrar, y a salir pulsando ALT-X).\n"
  162.              "   /D  Arranca directamente la utilidad 765DEBUG 4.0\n"
  163.              "   /T  Arranca directamente la utilidad FDTR (se admite unidad).\n"
  164.              "   /M  Fuerza la presentación en  modo texto  (por defecto si no hay\n"
  165.              "       al menos una tarjeta VGA en el sistema).\n"
  166.              "   /25 Usar 25 líneas en vez de 30 (por defecto si no hay VGA o bajo\n"
  167.              "       Windows Enhanced -excepto Windows 95- u OS/2).\n"
  168.              "   /30 Usar 30 líneas si es posible (problemático en las ventanas de\n"
  169.              "       Windows Enhanced u OS/2: utilice además pantalla completa).\n"
  170.              "   /I  Conmuta de Español a Inglés o viceversa.\n\n"
  171.              " (C) 1994-1995 Ciriaco García de Celis - Grupo Universitario de Informática\n"
  172.              " C/Renedo, 2, 4-C; 47005 Valladolid (España) - ciri@gui.uva.es - 2:341/21.8\n");
  173.     else
  174.       printf("\n2M-INFO 3.0\n"
  175.              "   /Q  Skips the first introductory screen (equivalent to leave pressed\n"
  176.              "       a SHIFT key at the beginning, and to exit using ALT-X).\n"
  177.              "   /D  Starts running 765DEBUG 4.0 utility.\n"
  178.              "   /T  Starts running FDTR utility (drive letter supported).\n"
  179.              "   /M  Forces a text mode presentation (by default if the system hasn't\n"
  180.              "       at least a VGA card).\n"
  181.              "   /25 Use 25 lines instead 30 (by default if VGA card isn't present or\n"
  182.              "       under Windows Enhanced -except Windows 95- or OS/2).\n"
  183.              "   /30 Use 30 lines if possible  (it  can  be problematic under Windows\n"
  184.              "       Enhanced or OS/2 windows: use also full screen).\n"
  185.              "   /I  Conmutes from English to Spanish or vice versa.\n\n"
  186.              " (C) 1994-1995 Ciriaco García de Celis - Grupo Universitario de Informática\n"
  187.              " C/Renedo, 2, 4-C;  47005 Valladolid (Spain) - ciri@gui.uva.es - 2:341/21.8\n");
  188.   exit (1);
  189. }
  190.  
  191.  
  192. void ProcesaParametros (int nump, char **pmts, Parametros *cmd)
  193. {
  194.   int  i, pm, ayuda=0, mdi=0, mndm=0, mtxt=0,
  195.               md=0, mt=0, m25=0, m30=0, unidad=0, midx=0;
  196.   char *p;
  197.  
  198.   strcpy (ruta, pmts[0]);
  199.   for (i=strlen(ruta); (i>0) && (ruta[i] != '\\'); i--);
  200.   ruta[i+1]=0;
  201.  
  202.   for (pm=1; pm<nump; pm++) {
  203.     strupr (pmts[pm]);
  204.     if (strstr(pmts[pm],"/?")!=NULL) ayuda++;
  205.     else if ((strstr(pmts[pm],"/H")!=NULL) && (strlen(pmts[pm])==2)) ayuda++;
  206.     else if (strstr(pmts[pm],"/IDX")!=NULL) midx++;
  207.     else if (strstr(pmts[pm],"/I")!=NULL) {mdi++; sp^=1;}
  208.     else if (strstr(pmts[pm],"/Q")!=NULL) mndm++;
  209.     else if (strstr(pmts[pm],"/M")!=NULL) mtxt++;
  210.     else if (strstr(pmts[pm],"/D")!=NULL) md++;
  211.     else if (strstr(pmts[pm],"/T")!=NULL) mt++;
  212.     else if (strstr(pmts[pm],"/25")!=NULL) m25++;
  213.     else if (strstr(pmts[pm],"/30")!=NULL) m30++;
  214.     else if ((p=strstr(pmts[pm],":"))!=NULL) {
  215.       unidad = *(--p);
  216.       if ((unidad<'A') || (unidad>'Z')) unidad=0; else unidad -= 'A';
  217.       }
  218.     else ayuda++;
  219.     }
  220.  
  221.   cmd->Ayuda    = ayuda;
  222.   cmd->ModoI    = mdi;
  223.   cmd->NoDemo   = mndm;
  224.   cmd->ModoTxt  = mtxt;
  225.   cmd->Modo765  = md;
  226.   cmd->ModoTest = mt;
  227.   cmd->Modo25   = m25;
  228.   cmd->Modo30   = m30;
  229.   cmd->HazIdx   = midx;
  230.   cmd->Unidad   = unidad;
  231. }
  232.  
  233.  
  234. int ExisteVga()
  235. {
  236.   union REGS r;
  237.  
  238.   r.x.ax=0x1A00; int86 (0x10, &r, &r);
  239.   return ((r.x.ax & 0xFF)==0x1A);
  240. }
  241.  
  242.  
  243. int Tecla()
  244. {
  245.   int t;
  246.  
  247.   while (kbhit()) getch(); t=getch(); if (!t) t=getch() << 8;
  248.   return (t);
  249. }
  250.  
  251.  
  252. int Hay2M3()     /* devolver 1 si 2M 3.X está instalado */
  253. {
  254.   int entrada, instalado=0;
  255.   union REGS r; struct SREGS s;
  256.  
  257.   for (entrada=0xc0; (entrada<=0xff) && (!instalado); entrada++) {
  258.     r.x.ax=entrada << 8; s.es=0x1492; r.x.di=0x1992;
  259.     int86x (0x2f, &r, &r, &s);
  260.     if (r.x.ax==0xFFFF)
  261.       if ((peek(s.es,r.x.di-4)==9002) && (peek(s.es,r.x.di-2)==10787))
  262.         if (strstr (MK_FP(s.es, r.x.di),"2M:3.")) instalado=1;
  263.         if (strstr (MK_FP(s.es, r.x.di),"2MX:3.")) instalado=1;
  264.     }
  265.   return (instalado);
  266. }
  267.  
  268.  
  269. int EsOS2 (void)   /* Devolver 1 si corriendo bajo OS/2 */
  270. {
  271.   union REGS r;
  272.  
  273.   if (_osmajor >= 3) {
  274.       r.x.ax=0x4010;
  275.       int86 (0x2F, &r, &r);
  276.       return (r.x.ax != 0x4010);
  277.       }
  278.     else return (0);   /* DOS 2.X, evitar llamada a INT 2Fh */
  279. }
  280.  
  281.  
  282. int EsWinEnh (void)   /* Devolver versión de Windows Enhanced */
  283. {
  284.   union REGS r;
  285.  
  286.   if (_osmajor >= 3) {
  287.       r.x.ax=0x1600;
  288.       int86 (0x2F, &r, &r);
  289.       if (!r.h.al) r.h.ah=0;
  290.       return ((r.h.al << 8) | r.h.ah);
  291.       }
  292.     else return (0);   /* DOS 2.X, evitar llamada a INT 2Fh */
  293. }
  294.  
  295.  
  296. int CargarGalaxia()
  297. {
  298.   int          f, i, x, y, tramas[12][2];
  299.   long         lbloque, posic, lgrafico, lbuffer, byte;
  300.   FichMultCiri imagen;
  301.   char         *buffer, *grafico, *pg, *pb, car, nfich[64], id[16];
  302.   union  REGS  r;
  303.   struct SREGS s;
  304.  
  305.   strcpy (nfich, ruta); strcat (nfich, FICH_FMC);
  306.  
  307.   if ((f=open(nfich, O_RDONLY | O_BINARY))==-1) return (FALTA_FMC);
  308.   lseek (f, FMC_ID_OFF, SEEK_SET);
  309.   if (read (f, id, 16)==-1) return (ERROR_FMC);
  310.   if (strcmp(id, FMC_ID)) return (ERROR_FMC);
  311.  
  312.   posic = FMC_ID_HEAD;
  313.   do {
  314.     if (posic>=filelength(f)) return (ERROR_FMC);
  315.     do {
  316.       lseek (f, posic, SEEK_SET);
  317.       if (read (f, &imagen, sizeof(FichMultCiri))==-1) return (ERROR_FMC);
  318.       posic += imagen.lbloque;
  319.     } while ((imagen.tipo != FMC_GRAFICO) && (posic<filelength(f)));
  320.   } while (strcmp(imagen.nombre, "Galaxia"));
  321.  
  322.   if (!(imagen.atributos & 1)) return (ERROR_FMC);  /* no comprimido */
  323.  
  324.   lgrafico=imagen.info.gr.lx * imagen.info.gr.ly + 64L*3;
  325.   lbuffer=imagen.lbloque - sizeof(FichMultCiri);
  326.   if ((grafico=farmalloc(lgrafico))==NULL) return (POCA_MEM);
  327.   if ((buffer=farmalloc(lbuffer))==NULL) {
  328.     farfree (grafico);
  329.     return (POCA_MEM);
  330.     }
  331.  
  332.   if (read (f, buffer, lbuffer)==-1) {
  333.     farfree (buffer);
  334.     farfree (grafico);
  335.     return (ERROR_FMC);
  336.     }
  337.   close (f);
  338.  
  339.   pg=grafico; pb=buffer;
  340.   for (byte=0; byte < lbuffer; byte++, pb++) {  /* descomprimir */
  341.     car = *pb & 0x3F;
  342.     switch (*pb & 0xC0) {
  343.       case  64: *pg++=car; *pg++=car; break;
  344.       case 128: *pg++=car; *pg++=car; *pg++=car; break;
  345.       case 192: for (i=0, pb++; i<*pb; i++) *pg++=car; byte++; break;
  346.       default:  *pg++=car;  break;
  347.       }
  348.     }
  349.  
  350.   farfree (buffer);
  351.  
  352.   if (lgrafico < pg-grafico) {
  353.     farfree (grafico);
  354.     return (ERROR_FMC);
  355.     }
  356.  
  357.   r.x.ax=0x1012; r.x.bx=0; r.x.cx=64;
  358.   s.es=FP_SEG(grafico); r.x.dx=FP_OFF(&grafico[r.x.bx]);
  359.   int86x (0x10, &r, &r, &s);  /* establecer paleta */
  360.  
  361.   PintaBitMap (&grafico[192], imagen.info.gr.lx,
  362.                0, 0, imagen.info.gr.lx, imagen.info.gr.ly, 160, 0, 0);
  363.  
  364.   PintaBitMap (&grafico[192], imagen.info.gr.lx,
  365.                0, 0, imagen.info.gr.lx, imagen.info.gr.ly, 0, 166-80, 1);
  366.  
  367.   tramas[0][0]=0;    tramas[0][1]=0;
  368.   tramas[1][0]=115;  tramas[1][1]=32;
  369.   tramas[2][0]=0;    tramas[2][1]=32;
  370.   tramas[3][0]=19;   tramas[3][1]=32;
  371.   tramas[4][0]=32;   tramas[4][1]=160;
  372.   tramas[5][0]=34;   tramas[5][1]=192;
  373.   tramas[6][0]=16;   tramas[6][1]=160;
  374.   tramas[7][0]=0;    tramas[7][1]=64;
  375.   tramas[8][0]=128;  tramas[8][1]=192;
  376.   tramas[9][0]=144;  tramas[9][1]=192;
  377.   tramas[10][0]=128; tramas[10][1]=0;
  378.   tramas[11][0]=92;  tramas[11][1]=32;
  379.  
  380.   srand (1);
  381.  
  382.   for (y=0; y<3; y++)
  383.     for (x=0; x<10; x++) {
  384.       i = random(10);
  385.       PintaBitMap (&grafico[192], imagen.info.gr.lx,
  386.                    tramas[i][0], tramas[i][1], 16, 32, x*16, y*32,
  387.                    random (2));
  388.       }
  389.  
  390.   for (y=10; y<13; y++)
  391.     for (x=0; x<10; x++) {
  392.       i = random(10);
  393.       PintaBitMap (&grafico[192], imagen.info.gr.lx,
  394.                    tramas[i][0], tramas[i][1], 16, y==12?16:32,
  395.                    x*16, y*32, random(2));
  396.       }
  397.  
  398.   for (y=0; y<6; y++)
  399.     for (x=10; x<20; x++) {
  400.       i = random(10);
  401.       PintaBitMap (&grafico[192], imagen.info.gr.lx,
  402.                    tramas[i][0], tramas[i][1], 16, y==5?20:32,
  403.                    x*16, y*32+220, random(2));
  404.       }
  405.  
  406.   PintaBitMap (&grafico[192], imagen.info.gr.lx,
  407.                tramas[10][0], tramas[10][1], 16, 32, 90, 96, 0);
  408.   PintaBitMap (&grafico[192], imagen.info.gr.lx,
  409.                tramas[11][0], tramas[11][1], 16, 32, 128, 96, 0);
  410.   PintaBitMap (&grafico[192], imagen.info.gr.lx,
  411.                tramas[10][0], tramas[10][1], 16, 32, 165, 292, 1);
  412.   PintaBitMap (&grafico[192], imagen.info.gr.lx,
  413.                tramas[11][0], tramas[11][1], 16, 32, 220, 288, 1);
  414.  
  415.   farfree (grafico);
  416.  
  417.   return (0);
  418. }
  419.  
  420.  
  421. int VgaPantallaIni()
  422. {
  423.   int err=0, errg=0;
  424.  
  425.   vgahi256();
  426.   PaletaIni();
  427.   setpage (1);
  428.   showpage (1);
  429.   Paciencia();
  430.   setpage (0);
  431.  
  432.   if (!(err=CargarGalaxia())) {
  433.       Imprimir2M();
  434.       ImprimirLogo();
  435.       }
  436.     else
  437.       ImprimirError (err);
  438.  
  439.   errg |= Luminosidad (DESCENDENTE);
  440.   showpage (0);
  441.   if (!errg)
  442.     errg |= Luminosidad (ASCENDENTE);
  443.  
  444.   if ((err) && ((bioskey(1) & 0xFF) != 0x1B)) Tecla();
  445.   return (err | errg);
  446. }
  447.  
  448.  
  449. void VgaPantallaFin()
  450. {
  451.   int err;
  452.  
  453.   vgahi256();
  454.   PaletaFin();
  455.   setpage (1);
  456.   showpage (1);
  457.   Paciencia();
  458.   setpage (0);
  459.  
  460.   if (!(err=CargarGalaxia())) {
  461.       Imprimir2M();
  462.       ImprimirCardWare();
  463.       }
  464.     else
  465.       ImprimirError (err);
  466.  
  467.   showpage (0);
  468. }
  469.  
  470.  
  471. void Estrellas()
  472. {
  473.   unsigned register x, i;
  474.   unsigned *pantalla;
  475.   unsigned tpant, nc, b1, b2, b3, b4;
  476.  
  477.   if ((peekb(0x40, 0x49) & 0x7F) == 7) {
  478.       pantalla = MK_FP (0xB000, 0);
  479.       nc=6; b1=b2=2; b3=b4=10;
  480.       }
  481.     else {
  482.       pantalla = MK_FP (0xB800, 0);
  483.       nc=1; b1=1; b2=3; b3=9; b4=11;
  484.       }
  485.  
  486.   tpant = (peekb(0x40, 0x84)+1)*80;
  487.  
  488.   for (i=0; i < tpant; i++) pantalla[i]=' ';
  489.  
  490.   semilla=99;
  491.   for (i=0; i < (tpant/20); i++) {
  492.     x = rnd(tpant) << 1; pantalla[x] =   7 | ((rnd(nc)+b1) << 8);
  493.     x = rnd(tpant) << 1; pantalla[x] =  46 | ((rnd(nc)+b2) << 8);
  494.     x = rnd(tpant) << 1; pantalla[x] = 249 | ((rnd(nc)+b3) << 8);
  495.     x = rnd(tpant) << 1; pantalla[x] = 250 | ((rnd(nc)+b4) << 8);
  496.     }
  497. }
  498.  
  499.  
  500. void escribir2M (char *mensaje)
  501. {
  502.   int i;
  503.   char      *pantalla;
  504.  
  505.   gotoxy (8, wherey()+1);
  506.   pantalla = MK_FP ((peekb(0x40, 0x49) & 0x7F) == 7 ? 0xB000:0xB800,
  507.     (wherex() + wherey()*80)*2);
  508.  
  509.   for (i=0; i<strlen(mensaje); i++)
  510.     switch (mensaje[i]) {
  511.       case ' ': pantalla+=2; break;
  512.       case '▒': *pantalla++='▒';
  513.                 if (i<35) *pantalla++=10; else *pantalla++=109;
  514.                 break;
  515.       case '█':
  516.       case '▄':
  517.       case '▀': *pantalla++=mensaje[i];
  518.                 if (i<35) *pantalla++=10; else *pantalla++=5;
  519.                 break;
  520.       }
  521. }
  522.  
  523.  
  524. void LogoTxt()
  525. {
  526.   textbackground (0);
  527.   Estrellas();
  528.  
  529.   gotoxy (1, 4);
  530.   escribir2M("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄  ▒▒▒▒▄      ▒▒▒▒▄");
  531.   escribir2M("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█  ▒▒▒▒▒▄    ▒▒▒▒▒█");
  532.   escribir2M(" ▀▀▀▀▀▀▀▀▀▀▒▒▒▒█  ▒▒▒▒▒▒▄  ▒▒▒▒▒▒█");
  533.   escribir2M("           ▒▒▒▒█  ▒▒▒▒▒▒▒▄▒▒▒▒▒▒▒█");
  534.   escribir2M("           ▒▒▒▒█  ▒▒▒▒█▒▒▒▒▒█▒▒▒▒█");
  535.   escribir2M("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█  ▒▒▒▒█ ▒▒▒█▀▒▒▒▒█     ▒▒▒▒▒▒▒▒▒▒▄     ▒▒▒▒▒▒▒▒▒▒▄");
  536.   escribir2M("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█  ▒▒▒▒█  ▒█▀ ▒▒▒▒█      ▀▀▀▀▀▀▀▒▒█     ▒▒█▀▀▀▀▀▒▒█");
  537.   escribir2M("▒▒▒▒█▀▀▀▀▀▀▀▀▀▀▀  ▒▒▒▒█   ▀  ▒▒▒▒█             ▒▒█     ▒▒█     ▒▒█");
  538.   escribir2M("▒▒▒▒█             ▒▒▒▒█      ▒▒▒▒█        ▒▒▒▒▒▒▒█     ▒▒█     ▒▒█");
  539.   escribir2M("▒▒▒▒█             ▒▒▒▒█      ▒▒▒▒█         ▀▀▀▀▒▒█     ▒▒█     ▒▒█");
  540.   escribir2M("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄  ▒▒▒▒█      ▒▒▒▒█             ▒▒█     ▒▒█     ▒▒█");
  541.   escribir2M("▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█  ▒▒▒▒█      ▒▒▒▒█     ▒▒▒▒▒▒▒▒▒▒█ ▒▒▄ ▒▒▒▒▒▒▒▒▒▒█");
  542.   escribir2M(" ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   ▀▀▀▀       ▀▀▀▀      ▀▀▀▀▀▀▀▀▀▀  ▀▀  ▀▀▀▀▀▀▀▀▀▀");
  543. }
  544.  
  545.  
  546. void CursorOff (void)
  547. {
  548.   union REGS regs;
  549.  
  550.   regs.x.ax=0x200; regs.x.bx=peekb(0x40,0x62)<<8;
  551.   regs.h.dl=1; regs.h.dh=63; int86 (0x10, ®s, ®s);
  552. }
  553.  
  554.  
  555. void BrilloOn (void)
  556. {
  557.   union REGS regs;
  558.  
  559.   if (peekb(0x40, 0x49)!=7) {       /* evitarlo en MDA */
  560.     regs.x.ax=0x1003; regs.x.bx=0;
  561.     int86 (0x10, ®s, ®s);
  562.     }
  563. }
  564.  
  565.  
  566. void TxtPantallaIni()
  567. {
  568.   LogoTxt();
  569.  
  570.   textcolor (9);
  571.   if (sp) {
  572.       gotoxy (22,19);
  573.       cputs("M A S   A L L A   D E L   L I M I T E"); }
  574.     else {
  575.       gotoxy (21,19);
  576.       cputs("F A R   A W A Y   F R O M   L I M I T S");
  577.       }
  578.  
  579.   textcolor (14); gotoxy (26+sp,22);
  580.   cputs("(C) Ciriaco García de Celis");
  581.  
  582.   gotoxy (36+sp,23); textcolor (12);
  583.   cputs("CiriSOFT");
  584.   CursorOff();
  585. }
  586.  
  587.  
  588. void TxtPantallaFin()
  589. {
  590.   LogoTxt();
  591.  
  592.   textcolor (12);
  593.  
  594.   if (sp) {
  595.       gotoxy (26, 3);
  596.       cputs ("¡ S E   M E   O L V I D A B A !"); }
  597.     else {
  598.       gotoxy (24, 3);
  599.       cputs ("I   R E M E M B E R   I T   N O W!");
  600.       }
  601.  
  602.   gotoxy (31, 19); textcolor (14);
  603.   if (sp)
  604.       cputs ("E S   C A R D W A R E");
  605.     else
  606.       cputs ("I S   C A R D W A R E");
  607.  
  608.   gotoxy (24, 21); textcolor (9);
  609.   if (sp)
  610.       cputs ("Recuerda enviar tu tarjeta postal a:");
  611.     else
  612.       cputs ("Don't forget to send your postcard to:");
  613.  
  614.   textcolor (10);
  615.   gotoxy (30, 22); cputs("Ciriaco García de Celis");
  616.   gotoxy (33, 23); cputs("C/Renedo, 2, 4-C");
  617.   gotoxy (33, 24); cputs("47005 Valladolid");
  618.   if (sp) {
  619.       gotoxy (37, 25); cputs("(España)"); }
  620.     else {
  621.       gotoxy (37, 25); cputs("(Spain)"); }
  622.  
  623.   CursorOff();
  624. }
  625.  
  626.  
  627. void Trampa (int vez)
  628. {
  629.   static char cmd[64];
  630.   char   prompt[80], *pantalla;
  631.   int    cy, pag, cols, x, car;
  632.  
  633.   pag=peekb(0x40, 0x62); cols=peek(0x40, 0x4A);
  634.   cy=peekb(0x40, 0x51+pag*2);
  635.   pantalla = MK_FP ((peekb(0x40, 0x49) & 0x7F) == 7 ? 0xB000:0xB800,
  636.                     peek (0x40, 0x4C) * pag);
  637.  
  638.   if (vez==INICIO) {
  639.       for (x=0; (x<cols) && (pantalla[(x+(cy-1)*cols)*2] != '>'); x++)
  640.         prompt[x]=pantalla[(x+(cy-1)*cols)*2];
  641.       prompt[x++]='>'; prompt[x]=0;
  642.       memmove (pantalla,  /* evitar scroll hardware de nnansi.sys */
  643.                pantalla + (cols << 1), peek(0x40, 0x4C)-(cols << 1));
  644.       printf("%s", prompt); x=cmd[0]=0;
  645.       do {
  646.         car = getch();
  647.         if (!car) car = getch() << 8;
  648.           else if (car>=' ') cmd[x++]=car, cmd[x]=0, printf("%c", car);
  649.         if (((car==8) || (car==0x4B00)) && (x>0))
  650.           cmd[--x]=0, printf("%s", "\b \b");
  651.         } while ((car!=13) && (x<15));
  652.       }
  653.     else {
  654.       if (sp)
  655.           printf("\n        Nota:  Si ya ha enviado su tarjeta postal, la próxima vez"
  656.                  "\n        puede evitar este aviso abandonando el programa con ALT-X.\n");
  657.         else
  658.           printf("\n        Note:  If you have already sent your postcard, next time"
  659.                  "\n        you can avoid this advice exiting the program with ALT-X.\n");
  660.  
  661.       while (kbhit()) getch();
  662.       for (x=0; x<strlen(cmd); x++) ptecla (cmd[x]);
  663.       }
  664. }
  665.  
  666.  
  667. void PaletaIni()
  668. {
  669.   char         dac[256][3];
  670.   union  REGS  r;
  671.   struct SREGS s;
  672.   register     i;
  673.  
  674.   dac[000][R]=dac[000][G]=dac[000][B]=0;       /* negro */
  675.   for (i=64; i<110; i++) {                     /* '2M' */
  676.     dac[i][R]=i-64+18;
  677.     dac[i][G]=((i-64) >> 1) + 18;
  678.     dac[i][B]=0;
  679.     }
  680.   for (i=110; i<155; i++) {                    /* '3.0' */
  681.     dac[i][R]=i-109+19;
  682.     dac[i][G]=i-109+19;
  683.     dac[i][B]=0;
  684.     }
  685.   for (i=155; i<199; i++) {                    /* 'Ciriaco...' */
  686.     dac[i][R]=(i-155+20) >> 4;
  687.     dac[i][G]=i-155+20;
  688.     dac[i][B]=(i-155+20) >> 4;
  689.     }
  690.   for (i=199; i<229; i++) {                    /* leyenda x2 */
  691.     dac[i][R]=(i-199)*7/4+11;
  692.     dac[i][G]=((i-199)*7/4+11)/3;
  693.     dac[i][B]=11;
  694.     }
  695.   for (i=229; i<244; i++) {                    /* x1 */
  696.     dac[i][R]=dac[i][G]=random(16);
  697.     dac[i][B]=random(16)+48;
  698.     }
  699.  
  700.   dac[255][R]=dac[255][G]=dac[255][B]=0;       /* negro */
  701.   dac[254][R]=dac[254][G]=0; dac[254][B]=48;   /* 'CiriSOFT' */
  702.  
  703.   r.x.ax=0x1012; r.x.bx=0; r.x.cx=256;
  704.   s.es=FP_SEG(dac); r.x.dx=FP_OFF(&dac[r.x.bx]);
  705.   int86x (0x10, &r, &r, &s);
  706. }
  707.  
  708.  
  709. void PaletaFin()
  710. {
  711.   char         dac[256][3];
  712.   union  REGS  r;
  713.   struct SREGS s;
  714.   register     i;
  715.  
  716.   dac[000][R]=dac[000][G]=dac[000][B]=0;       /* negro */
  717.   for (i=64; i<110; i++) {                     /* '2M' */
  718.     dac[i][R]=i-64+18;
  719.     dac[i][G]=((i-64) >> 1) + 18;
  720.     dac[i][B]=0;
  721.     }
  722.   for (i=110; i<155; i++) {                    /* '3.0' */
  723.     dac[i][R]=i-109+19;
  724.     dac[i][G]=i-109+19;
  725.     dac[i][B]=0;
  726.     }
  727.   for (i=155; i<174; i++) {                    /* 'Olvido' */
  728.     dac[i][R]=((i-155)*3+9) >> 4;
  729.     dac[i][G]=(i-155)*3+9;
  730.     dac[i][B]=((i-155)*3+9) >> 4;
  731.     }
  732.   for (i=174; i<201; i++) {                    /* 'CardWare' */
  733.     dac[i][R]=(i-174)*7/4+16;
  734.     dac[i][G]=((i-174)*7/4+16)/3;
  735.     dac[i][B]=16;
  736.     }
  737.   for (i=201; i<225; i++) {                    /* 'Postal...' */
  738.     dac[i][R]=0;
  739.     dac[i][G]=(i-201)*2+17;
  740.     dac[i][B]=(i-201)*2+17;
  741.     }
  742.   for (i=225; i<239; i++) {                    /* 'C/...' */
  743.     dac[i][R]=(i-225)*4+11;
  744.     dac[i][G]=(i-225)*4+11;
  745.     dac[i][B]=(i-225)*4+11;
  746.     }
  747.  
  748.   dac[255][R]=dac[255][G]=dac[255][B]=0;       /* negro */
  749.  
  750.   r.x.ax=0x1012; r.x.bx=0; r.x.cx=256;
  751.   s.es=FP_SEG(dac); r.x.dx=FP_OFF(&dac[r.x.bx]);
  752.   int86x (0x10, &r, &r, &s);
  753. }
  754.  
  755.  
  756. void Paciencia()
  757. {
  758.   if (sp)
  759.       prcad ("Un momento...", 115, 180, 1, 2, 198-2, 0xFF, 2);
  760.     else
  761.       prcad ("One moment...", 115, 180, 1, 2, 198-2, 0xFF, 2);
  762. }
  763.  
  764.  
  765. int Luminosidad (int modo)
  766. {
  767.   static   char dac[256][3];
  768.   register      i, j;
  769.   unsigned int  tm, tmout, tec;
  770.   unsigned int  far *cbios=MK_FP(0x40, 0x6C);  /* reloj del sistema */
  771.   unsigned char p;
  772.  
  773.   if (modo==DESCENDENTE) {
  774.       for (i=0; i<256; i++) {          /* anotar la paleta activa */
  775.         disable();
  776.         outportb (0x3C7, i);
  777.         dac [i][0] = inportb (0x3C9);  /* R */
  778.         dac [i][1] = inportb (0x3C9);  /* G */
  779.         dac [i][2] = inportb (0x3C9);  /* B */
  780.         enable();
  781.         }
  782.       for (i=64; i>=0; i--) {          /* claridad descendente  */
  783.         tec = bioskey(1) & 0xFF;
  784.         if (tec == 0x1B) break; else if (tec) (void) bioskey(0);
  785.         for (j=0; j<256; j++) {
  786.         if  (!(j % 128)) {
  787.           tmout=0;
  788.           do {                         /* esperar retrazo vertical */
  789.             p = inportb(0x3DA) & 8;
  790.             if (tm != *cbios) {
  791.               tm = *cbios; tmout++;
  792.               if (tmout>9) goto aborta;
  793.               }
  794.             } while (p == 8);
  795.           do {                         /* esperar su fin */
  796.             p = inportb(0x3DA) & 8;
  797.             if (tm != *cbios) {
  798.               tm = *cbios; tmout++;
  799.               if (tmout>9) goto aborta;
  800.               }
  801.             } while (p != 8);
  802.           }
  803.           disable();
  804.           outportb (0x3C8, j);
  805.           outportb (0x3C9, dac[j][0]*i >> 6);
  806.           outportb (0x3C9, dac[j][1]*i >> 6);
  807.           outportb (0x3C9, dac[j][2]*i >> 6);
  808.           enable();
  809.           }
  810.         }
  811.       }
  812.     else if (modo==ASCENDENTE) {       /* claridad ascendente */
  813.       for (i=0; i<=64; i++) {
  814.         tec = bioskey(1) & 0xFF;
  815.         if (tec == 0x1B) break; else if (tec) (void) bioskey(0);
  816.         for (j=0; j<256; j++) {
  817.         if  (!(j % 128)) {
  818.           tmout=0;
  819.           do {                         /* esperar retrazo vertical */
  820.             p = inportb(0x3DA) & 8;
  821.             if (tm != *cbios) {
  822.               tm = *cbios; tmout++;
  823.               if (tmout>9) goto aborta;
  824.               }
  825.             } while (p == 8);
  826.           do {                         /* esperar su fin */
  827.             p = inportb(0x3DA) & 8;
  828.             if (tm != *cbios) {
  829.               tm = *cbios; tmout++;
  830.               if (tmout>9) goto aborta;
  831.               }
  832.             } while (p != 8);
  833.           }
  834.           disable();
  835.           outportb (0x3C8, j);
  836.           outportb (0x3C9, dac[j][0]*i >> 6);
  837.           outportb (0x3C9, dac[j][1]*i >> 6);
  838.           outportb (0x3C9, dac[j][2]*i >> 6);
  839.           enable();
  840.           }
  841.         }
  842.       }
  843.  
  844.   aborta:
  845.   return (tmout > 9);  /* posible fallo HW en entornos avanzados */
  846. }
  847.  
  848.  
  849. void prcad (char *cad, int x, int y, int largo, int alto,
  850.             int tinta, int papel, int escala)
  851. {
  852.   while (*cad) {
  853.     prcar (*cad, x, y, largo, alto, tinta, papel, escala);
  854.     x+=largo*8;
  855.     cad++;
  856.     }
  857. }
  858.  
  859.  
  860. void Imprimir2M()
  861. {
  862.   int x, y, cy, tt;
  863.  
  864.   prcar ('2', 60,  100, 8, 10, 64+15+45, 0xFF, -1);
  865.   prcar (255, 124, 100, 8, 10, 64-15,    0xFF,  1);
  866.  
  867.   for (y=-148; y<-112; y++)         /* completar la 'M' */
  868.     for (x=140; x<152; x++) {
  869.       cy = (x << 1) + y;
  870.       tt = (cy >> 1) - 1;
  871.       setpix (x, cy, tt);
  872.       setpix (303-x, cy, tt);
  873.       }
  874.  
  875.   prcar ('3', 200, 160, 3, 5, 110+15+44, 0xFF, -2);
  876.   prcar ('.', 221, 160, 2, 5, 110-15,    0xFF,  2);
  877.   prcar ('0', 235, 160, 3, 5, 110-15,    0xFF,  2);
  878. }
  879.  
  880.  
  881. void ImprimirLogo()
  882. {
  883.   prcad ("CiriSOFT", 95, 230, 2, 6, 254, 0xFF, 0);
  884.   prcad ("Ciriaco García de Celis", 67, 244, 1, 4, 155-4, 0xFF, 2);
  885.   if (sp)
  886.       prcad ("Más allá... del límite", 71, 360, 1, 2, 199-2, 0xFF, 2);
  887.     else
  888.       prcad ("Far away... from limits", 67, 360, 1, 2, 199-2, 0xFF, 2);
  889. }
  890.  
  891.  
  892. void ImprimirError (int error)
  893. {
  894.   if (sp)
  895.       switch (error) {
  896.         case FALTA_FMC: prcad ("¡Fichero *.FMC no encontrado!",
  897.                         40, 180, 1, 2, 110-2, 0xFF, 2); break;
  898.         case POCA_MEM:  prcad ("Memoria insuficiente para",
  899.                         55, 170, 1, 2, 110-2, 0xFF, 2);
  900.                         prcad ("pantalla de presentación.",
  901.                         55, 200, 1, 2, 110-2, 0xFF, 2); break;
  902.         case ERROR_FMC: prcad ("¡Problemas con el fichero *.FMC!",
  903.                         30, 180, 1, 2, 110-2, 0xFF, 2); break;
  904.         }
  905.     else switch (error) {
  906.         case FALTA_FMC: prcad ("File *.FMC not found!",
  907.                         78, 180, 1, 2, 110-2, 0xFF, 2); break;
  908.         case POCA_MEM:  prcad ("Insufficient memory",
  909.                         87, 170, 1, 2, 110-2, 0xFF, 2);
  910.                         prcad ("for initial screen.",
  911.                         87, 200, 1, 2, 110-2, 0xFF, 2); break;
  912.         case ERROR_FMC: prcad ("Problems with *.FMC file!",
  913.                         63, 180, 1, 2, 110-2, 0xFF, 2); break;
  914.         }
  915.  
  916.   if (sp)
  917.       prcad ("Pulse una tecla para continuar.",35, 340, 1, 2, 198-2, 0xFF, 2);
  918.     else
  919.       prcad ("Press any key to continue.",60, 340, 1, 2, 198-2, 0xFF, 2);
  920. }
  921.  
  922.  
  923. void ImprimirCardWare()
  924. {
  925.   if (sp) {
  926.       prcad ("¡Se me olvidaba!", 96, 20, 1, 5, 155-6, 0xFF, 1);
  927.       prcad ("es CardWare", 28, 230, 3, 3, 174-9, 0xFF, 2);
  928.       prcad ("Recuerda enviar tu tarjeta postal a:", 17, 280, 1, 2, 201-6, 0xFF, 2);
  929.       }
  930.     else {
  931.       prcad ("I remember it now!", 84, 20, 1, 5, 155-6, 0xFF, 1);
  932.       prcad ("is CardWare", 26, 230, 3, 3, 174-9, 0xFF, 2);
  933.       prcad ("Don't forget to send your postcard to:", 9, 280, 1, 2, 201-6, 0xFF, 2);
  934.       }
  935.  
  936.   prcad ("Ciriaco García de Celis", 68, 320, 1, 1, 225-1, 0xFF, 2);
  937.   prcad ("C/Renedo 2,  4-C", 93, 340, 1, 1, 225-1, 0xFF, 2);
  938.   prcad ("47005 Valladolid", 93, 360, 1, 1, 225-1, 0xFF, 2);
  939.  
  940.   if (sp)
  941.       prcad ("(España)", 125, 380, 1, 1, 225-1, 0xFF, 2);
  942.     else
  943.       prcad ("(Spain)", 129, 380, 1, 1, 225-1, 0xFF, 2);
  944. }
  945.  
  946.  
  947. void ventana (operacion, x0, y0, x1, y1, tinta, papel)
  948. {
  949.   static char *memoria;
  950.   char   *pantalla;
  951.   int    i, t;
  952.  
  953.   if (operacion==ABRIR) {
  954.        if ((memoria = farmalloc (2L*(x1-x0+3)*(y1-y0+2)))!=NULL)
  955.          gettext (x0, y0, x1+2, y1+1, memoria);
  956.        textbackground (papel); if (tinta>7) t=tinta-8; else t=tinta;
  957.        textcolor (t+8);
  958.        gotoxy (x0, y0); putch('┌');
  959.        gotoxy (x0, y1); putch('└');
  960.        textcolor (t);
  961.        gotoxy (x1, y0); putch('┐');
  962.        gotoxy (x1, y1); putch('┘');
  963.        for (i=1; i<x1-x0; i++) {
  964.          textcolor (t+8); gotoxy (x0+i, y0); putch('─');
  965.          textcolor (t);   gotoxy (x0+i, y1); putch('─');
  966.          }
  967.        for (i=1; i<y1-y0; i++) {
  968.          textcolor (t+8); gotoxy (x0, y0+i); putch('│');
  969.          textcolor (t); gotoxy (x1, y0+i); putch('│');
  970.          }
  971.        window  (x0+1, y0+1, x1-1, y1-1);
  972.        textcolor (tinta); clrscr();
  973.        pantalla = MK_FP ((peekb(0x40, 0x49) & 0x7F) == 7 ? 0xB000:0xB800, 0);
  974.        t = ((y1*80 + x0) << 1) + 1;
  975.        for (i=1; i<x1-x0+2; i++) pantalla[t+(i<<1)]=7;
  976.        t = ((y0*80 + x1) << 1) + 1;
  977.        for (i=0; i<y1-y0; i++)
  978.          pantalla[t+i*160]=pantalla[t+i*160+2]=7;
  979.        }
  980.      else {
  981.        puttext (x0, y0, x1+2, y1+1, memoria);
  982.        if (memoria != NULL) farfree (memoria);
  983.        window (1, 1, 80, 25);
  984.        }
  985. }
  986.  
  987.  
  988. void Marco3dg (cx, cy, lx, ly, foco, tin, pap, banda)
  989. {
  990.   int tb, x, y, w;
  991.  
  992.   w = _wscroll; _wscroll=0;
  993.  
  994.   if (tin<8) tb=tin+8; else tb=tin;
  995.  
  996.   if (foco) {
  997.       textbackground (pap); textcolor (tb);
  998.  
  999.       for (y=cy; y < cy+ly; y++) {
  1000.         textbackground (pap); gotoxy (cx, y); putch('▐');
  1001.         }
  1002.       for (x=cx+1; x < cx+lx-1; x++) {
  1003.         textbackground (banda); gotoxy (x, cy); putch('▀');
  1004.         }
  1005.  
  1006.       textcolor (8);
  1007.  
  1008.       for (y=cy; y < cy+ly; y++) {
  1009.         textbackground (pap); gotoxy (cx+lx-1, y); putch('▌');
  1010.         }
  1011.       for (x=cx+1; x < cx+lx-1; x++) {
  1012.         textbackground (banda); gotoxy (x, cy+ly-1); putch('▄');
  1013.         }
  1014.       }
  1015.     else {
  1016.       textbackground (pap); textcolor (8);
  1017.  
  1018.       for (y=cy; y < cy+ly; y++) {
  1019.         textbackground (banda); gotoxy (cx, y); putch('▐');
  1020.         }
  1021.       for (x=cx+1; x < cx+lx-1; x++) {
  1022.         textbackground (pap); gotoxy (x, cy); putch('▀');
  1023.         }
  1024.  
  1025.       textcolor (tb);
  1026.  
  1027.       for (y=cy; y < cy+ly; y++) {
  1028.         textbackground (banda); gotoxy (cx+lx-1, y); putch('▌');
  1029.         }
  1030.       for (x=cx+1; x < cx+lx-1; x++) {
  1031.         textbackground (pap); gotoxy (x, cy+ly-1); putch('▄');
  1032.         }
  1033.       }
  1034.  
  1035.   _wscroll = w;
  1036. }
  1037.  
  1038.  
  1039. void v3dg (cx, cy, lx, ly, foco, dis, tin, pap, banda)
  1040. {
  1041.   int  x, y, i;
  1042.   char txt[81];
  1043.  
  1044.   Marco3dg (cx, cy, lx, ly, foco, tin, pap, banda);
  1045.   Marco3dg (cx+dis*2, cy+dis, lx-dis*4, ly-dis*2, foco^1, tin, pap, banda);
  1046.   textbackground (banda);
  1047.  
  1048.   *txt=0;
  1049.   for (x=0; x < lx-2; x++) strcat (txt, " ");
  1050.   for (i=0; i<dis-1; i++) {
  1051.     gotoxy (cx+1, cy+1+i); cputs(txt);
  1052.     gotoxy (cx+1, cy+ly-dis+i); cputs(txt);
  1053.     }
  1054.   *txt=0;
  1055.   for (i=0; i < dis*2-1; i++) strcat (txt, " ");
  1056.   for (y=cy+1; y < ly; y++) {
  1057.     gotoxy (cx+1, y); cputs(txt);
  1058.     gotoxy (cx+lx-2*dis, y); cputs(txt);
  1059.     }
  1060.   textbackground (pap);
  1061. }
  1062.  
  1063.  
  1064. void Marco3df (cx, cy, lx, ly, foco, tin, pap)
  1065. {
  1066.   int tb, x, y, w;
  1067.  
  1068.   w = _wscroll; _wscroll=0;
  1069.  
  1070.   if (tin<8) tb=tin+8; else tb=tin;
  1071.  
  1072.   textbackground (pap); textcolor (foco?tb:8);
  1073.  
  1074.   gotoxy (cx, cy); putch('┌');
  1075.   for (y=cy+1; y < cy+ly-1; y++) {
  1076.     gotoxy (cx, y); putch('│');
  1077.     }
  1078.   gotoxy (cx, y); putch('└');
  1079.  
  1080.   for (x=cx+1; x < cx+lx-1; x++) {
  1081.     gotoxy (x, cy); putch('─');
  1082.     }
  1083.  
  1084.   textcolor (foco?8:tb);
  1085.  
  1086.   gotoxy (cx+lx-1, cy); putch('┐');
  1087.   for (y=cy+1; y < cy+ly-1; y++) {
  1088.     gotoxy (cx+lx-1, y); putch('│');
  1089.     }
  1090.   gotoxy (cx+lx-1, y); putch('┘');
  1091.  
  1092.   for (x=cx+1; x < cx+lx-1; x++) {
  1093.     gotoxy (x, cy+ly-1); putch('─');
  1094.     }
  1095.  
  1096.   _wscroll = w;
  1097. }
  1098.  
  1099.  
  1100. void v3df (cx, cy, lx, ly, foco, dis, tin, pap)
  1101. {
  1102.   Marco3df (cx, cy, lx, ly, foco, tin, pap);
  1103.   Marco3df (cx+dis*2, cy+dis, lx-dis*4, ly-dis*2, foco^1, tin, pap);
  1104. }
  1105.  
  1106.  
  1107. void v3d (cx, cy, lx, ly, dis)
  1108. {
  1109.   window (cx+dis*2+1, cy+dis+1, cx+lx-dis*2-2, cy+ly-dis-2);
  1110. }
  1111.  
  1112.  
  1113. void boton (int cx, int cy, int borde, int ttex, int t, int p, char *texto)
  1114. {
  1115.   int tb, tt;
  1116.  
  1117.   if (borde<8) { tb=borde+8; tt=borde;} else { tb=borde; tt=borde-8; }
  1118.  
  1119.   gotoxy (cx, cy);
  1120.   textbackground (tt); textcolor (tb); putch ('▌');
  1121.   textcolor (ttex); cputs (texto);
  1122.   textcolor (8); putch ('▐');
  1123.   textcolor (t); textbackground (p);
  1124. }
  1125.  
  1126.  
  1127. int input (char *cad, int modo, int maxcar, int tinta, int papel)
  1128. {
  1129.   int x, y, t, i, px, primeravez=1;
  1130.   static insercion=1;
  1131.  
  1132.   x=wherex(); y=wherey(); px = strlen (cad);
  1133.  
  1134.   gotoxy (x, y);
  1135.   textcolor (tinta+BLINK); textbackground (papel);
  1136.   cputs (cad);
  1137.   textcolor (tinta); for (i=px; i<maxcar; i++) putch(' ');
  1138.   gotoxy (x+px, y);
  1139.  
  1140.   do {
  1141.     if (insercion)
  1142.         _setcursortype (_NORMALCURSOR);
  1143.       else
  1144.         _setcursortype (_SOLIDCURSOR);
  1145.     if (!(t=getch())) t = getch() << 8;
  1146.     if ((primeravez) && (t!=8) && (t!=13) && (t<256)) cad[0]=px=0;
  1147.     primeravez=0;
  1148.     switch (t) {
  1149.       case 0x4B00: if (px) px--; break;
  1150.       case 0x4D00: if (px < strlen(cad)) px++; break;
  1151.       case 8:      if (px)
  1152.                      for (i=--px; i<=strlen(cad); i++) cad[i]=cad[i+1];
  1153.                    break;
  1154.       case 0x5300: for (i=px; i<=strlen(cad); i++) cad[i]=cad[i+1]; break;
  1155.       case 0x4700: px=0; break;
  1156.       case 0x4F00: px = strlen(cad); break;
  1157.       case 0x5200: insercion ^= 1;
  1158.       default:     if(
  1159.                        (t>=32) && (t<256) && (
  1160.                          (modo==0) ||
  1161.                          ((modo==1) && (t>='0') && (t<='9')) ||
  1162.                          ((modo==2) && (
  1163.                            ((t>='0') && (t<='9')) ||  /* Modo 0: Asc */
  1164.                            ((t>='a') && (t<='f')) ||  /* Modo 1: Dec */
  1165.                            ((t>='A') && (t<='F'))     /* Modo 2: Hex */
  1166.                            )
  1167.                          )
  1168.                        )
  1169.                      )
  1170.                      if (!insercion) {
  1171.                          if (px < maxcar) {
  1172.                            cad[strlen(cad)+1]=0;
  1173.                            cad[px++]=t;
  1174.                            }
  1175.                          }
  1176.                        else
  1177.                          if (strlen(cad) < maxcar) {
  1178.                            for (i=strlen(cad); i>=px; i--) cad[i+1]=cad[i];
  1179.                            cad[i+1]=t; px++;
  1180.                            }
  1181.                    break;
  1182.       }
  1183.     gotoxy (x, y); for (i=0; i<maxcar; i++) putch(' ');
  1184.     gotoxy (x, y); cputs (cad); gotoxy (x+px, y);
  1185.   } while ((t!=13) && (t!=27));
  1186.  
  1187.   if ((t==13) && (strlen(cad)==0)) t=27;  /* campo vacío -> ESC */
  1188.  
  1189.   return (t==13);
  1190. }
  1191.  
  1192.  
  1193. char *dec2str (unsigned num)
  1194. {
  1195.   static char cad[32];
  1196.  
  1197.   if (num >= 10) { cad[0]=num/10+'0'; num %= 10; } else cad[0]='0';
  1198.   cad[1]=num+'0';
  1199.   cad[2]=0;
  1200.  
  1201.   return (cad);
  1202. }
  1203.  
  1204.  
  1205. char *dec2strq (unsigned num)
  1206. {
  1207.   char *p;
  1208.  
  1209.   p=dec2str(num);
  1210.   if (*p=='0') p++;
  1211.   return (p);
  1212. }
  1213.  
  1214.  
  1215. char *dec3str (unsigned num)
  1216. {
  1217.   static char cad[32];
  1218.   int    i;
  1219.  
  1220.   if (num >= 100) { cad[0]=num/100+'0'; num %= 100; } else cad[0]='0';
  1221.   if (num >= 10) { cad[1]=num/10+'0'; num %= 10; } else cad[1]='0';
  1222.   cad[2]=num+'0';
  1223.   cad[3]=0;
  1224.  
  1225.   for (i=0; (i<2) && (cad[i]=='0'); i++) cad[i]=' ';
  1226.  
  1227.   return (cad);
  1228. }
  1229.  
  1230.  
  1231. char *dec3strq (unsigned num)
  1232. {
  1233.   char *p;
  1234.  
  1235.   p=dec3str(num);
  1236.   while (*p==' ') p++;
  1237.   return (p);
  1238. }
  1239.  
  1240.  
  1241. char *dec5str (unsigned num)
  1242. {
  1243.   static char cad[32];
  1244.   int    i;
  1245.  
  1246.   if (num >= 10000) { cad[0]=num/10000+'0'; num %= 10000; } else cad[0]='0';
  1247.   if (num >= 1000) { cad[1]=num/1000+'0'; num %= 1000; } else cad[1]='0';
  1248.   if (num >= 100) { cad[2]=num/100+'0'; num %= 100; } else cad[2]='0';
  1249.   if (num >= 10) { cad[3]=num/10+'0'; num %= 10; } else cad[3]='0';
  1250.   cad[4]=num+'0';
  1251.   cad[5]=0;
  1252.  
  1253.   for (i=0; (i<4) && (cad[i]=='0'); i++) cad[i]=' ';
  1254.  
  1255.   return (cad);
  1256. }
  1257.  
  1258.  
  1259. char *dec5strq (unsigned num)
  1260. {
  1261.   char *p;
  1262.  
  1263.   p=dec5str(num);
  1264.   while (*p==' ') p++;
  1265.   return (p);
  1266. }
  1267.  
  1268.  
  1269. int TipoDrive (int unidad)
  1270. {
  1271.   union REGS r;
  1272.  
  1273.   r.h.ah=8; r.h.dl=unidad; r.h.bl = 255;
  1274.   int86 (0x13, &r, &r);
  1275.  
  1276.   if ((r.x.flags & 1) || (r.h.bl==255)) return (-1);
  1277.   else return ((unsigned char) r.h.bl);
  1278. }
  1279.  
  1280.  
  1281. int HablaSp()       /* devolver 1 si mensajes en castellano */
  1282. {
  1283.   union REGS r; struct SREGS s;
  1284.   char info[64];
  1285.   int i, idioma, spl[]={54, 591, 57, 506, 56, 593, 503, 34, 63, 502,
  1286.              504, 212, 52, 505, 507, 595, 51, 80, 508, 598, 58, 3, 0};
  1287.  
  1288.   idioma=0;          /* supuesto el inglés */
  1289.  
  1290.   if (_osmajor>=3) {
  1291.     r.x.ax=0x3800; s.ds=FP_SEG(info); r.x.dx=FP_OFF(info);
  1292.     intdosx (&r, &r, &s);
  1293.     i=0; while (spl[i++]) if (spl[i-1]==r.x.bx) idioma=1;
  1294.     }
  1295.  
  1296.   return (idioma);
  1297. }
  1298.  
  1299.  
  1300. void main (int argc, char *argv[])
  1301. {
  1302.   Parametros cmd;
  1303.   int        NoDemo;
  1304.  
  1305.   sp = HablaSp();
  1306.  
  1307.   ProcesaParametros (argc, argv, &cmd);
  1308.   if (cmd.Ayuda) Ayuda();
  1309.  
  1310.   Vram (PRESERVAR);
  1311.  
  1312.   NoDemo = cmd.NoDemo || cmd.Modo765 || cmd.ModoTest;
  1313.  
  1314.   if (!NoDemo && (!(*KeybShifts & 3)))
  1315.     if (ExisteVga() && !cmd.ModoTxt) {
  1316.         if (!(NoDemo = VgaPantallaIni())) /* posible fallo de la función */
  1317.         do getch(); while (kbhit());
  1318.         }
  1319.       else {
  1320.         TxtPantallaIni();
  1321.         do getch(); while (kbhit());
  1322.         }
  1323.  
  1324.   Vram (RESTAURAR);
  1325.   Vram (PRESERVAR);
  1326.  
  1327.   if (cmd.ModoTest) fdtr (1, cmd.Unidad);
  1328.   else if (cmd.Modo765) debug765();
  1329.   else if (VerFicheroDoc (ruta, FICH_DOC, FICH_IDX, &cmd)) NoDemo=1;
  1330.  
  1331.   if (!NoDemo) {
  1332.       Vram (MOSTRAR);
  1333.       Trampa (INICIO);
  1334.       if (ExisteVga() && !cmd.ModoTxt)
  1335.           VgaPantallaFin();
  1336.         else
  1337.           TxtPantallaFin();
  1338.  
  1339.       Tecla();
  1340.  
  1341.       Vram (RESTAURAR);
  1342.       Trampa (FIN);
  1343.       }
  1344.     else Vram (RESTAURAR);
  1345. }
  1346.